# coding:utf8

from project import IpState


class _SustainIPs:
    def __init__(self):
        self.__SustainIps_dict = {"192.168.10.100": IpState.STATE_INVALID}
        pass
        
        
        
    def set_dict_from_IPState_Obj(self, ipstate_s: list):
        if not isinstance(ipstate_s, list) and ipstate_s == []:
            return
        
        self.__SustainIps_dict = {}
        
        for ipate in ipstate_s:
            if isinstance(ipate, IpState): pass
            self.__SustainIps_dict.setdefault(ipate.ip, ipate.state)
        pass
    
    
    def get_IpSate_obj_from_dict(self):
        if self.__SustainIps_dict == {} : return None
        
        ipate_list = []
        
        for ipstr in self.__SustainIps_dict:
            value_state = self.__SustainIps_dict.get(ipstr)
            ipat = IpState(ipstr)
            ipat.state = value_state
            ipate_list.append(ipat)
        
        return ipate_list
        

class ConfigIpOnline(_SustainIPs):
    def __init__(self):
        super(ConfigIpOnline, self).__init__()
        
        self.pc_tail = '151'
        self.thread_sleep_time = 2
        self.ping_distance_time = 2

# if isinstance(config_ip_online, ConfigIpOnline): pass


